package roborally.Exceptions;

import roborally.Robot;
import be.kuleuven.cs.som.annotate.Basic;
import be.kuleuven.cs.som.annotate.Immutable;
import be.kuleuven.cs.som.annotate.Raw;

/**
 * A class of exceptions signaling illegal amounts to add to the coordinates of a robot.
 * Each illegal amount exception involves the illegal amount, the robot that was intended to move
 * and the type of destination-coordinate that was invalid (x or y).
 * 
 * @version 1.34
 * @author Michiel Ruelens & Dieter Naten
 */

public class IllegalAmountException extends RuntimeException {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Variable referencing the amount of this illegal amount exception.
	 * This is the amount of steps the robot was intended to move.
	 * This amount is negative if the robot was moving towards the origin (methods subtractX and subtractY).
	 * This amount is positive if the robot was moving away from the origin (methods addX and addY).
	 */
	private final long amount;
	/**
	 * Variable referencing the robot of this illegal amount exception.
	 */
	private final Robot robot;
	/**
	 * Variable referencing the type of coordinate of this illegal amount exception (x or y).
	 */
	private final String type;
	
	/**
	 * Initialize this new illegal amount exception with the given amount, original coordinate and type of coordinate.
	 * 
	 * @param 	robot
	 * 			The robot that was intended to move before the exception was thrown.
	 * @param	Xpos
	 * 			The original coordinate of the robot.
	 * @param	type
	 * 			The type of coordinate this exception is about. This can be either "x" or "y".
	 * @post	The amount of this new illegal amount exception is equal to the given amount.
	 * 			| new.getAmount() == amount
	 * @post	The robot of this illegal amount exception is equal to the given robot.
	 * 			| new.getRobot() == robot
	 * @post	The type of this illegal amount exception is equal to the given type.
	 * 			| new.getType() == type
	 * @effect 	This illegal amount exception is further initialized as a new runtime exception involving no diagnostic message and no cause.
	 * 			| super()
	 */
	public IllegalAmountException (Robot robot, long amount, String type)
	{
		this.robot = robot;
		this.amount = amount;
		this.type = type;
	}
	
	/**
	 * Return the amount of this illegal amount exception.
	 */
	@Basic @Raw @Immutable
	public long getAmount()
	{
		return amount;
	}
	
	/**
	 * Return the robot of this illegal amount exception.
	 */
	@Basic @Raw @Immutable
	public Robot getRobot()
	{
		return robot;
	}
	
	/**
	 * Return the type of this illegal amount exception.
	 */
	@Basic @Raw @Immutable
	public String getType()
	{
		return type;
	}
	

}
